

<div class="wrapper">
        <form id="ftp_form" order="{{ order_name }}">
        <div id="add_ftp_content" order="{{ order_name }}" style="display:none">
            <table>
                <tr>
                    <td width="1">
                        Пользователь:
                    </td>
                </tr>
                <tr>
                    <td width="1">
                        <input type="text" name="ftp_user_name" order="{{ order_name }}" />
                    </td>
                    <td class="status" align="left"></td>
                </tr>
                <tr>
                    <td width="1">
                        Пароль:
                    </td>
                </tr>
                <tr>
                    <td width="1">
                        <input type="text" name="ftp_new_password" order="{{ order_name }}" />
                    </td>
                    <td class="status" align="left"></td>
                </tr>
                <tr>
                    <td>
                        <a href="" id="generate_ftp_password" order="{{ order_name }}">сгенерировать</a>
                        <div id="load_icon_generate_ftp_new_password" order="{{ order_name }}" style="display:none">
                            Генерация пароля <img alt="загрузка" src="{{ asset('bundles/billing/i/load.gif') }}">
                        </div>
                    </td>
                </tr>
                <tr>
                    <td width="1">
                        Директория:
                    </td>
                </tr>
                <tr>
                    <td width="1">
                        <input type="text" name="ftp_directory" order="{{ order_name }}" />
                    </td>
                    <td class="status" align="left"></td>
                </tr>
            </table>
            <a href="" id="add_ftp" order="{{ order_name }}">добавить</a>
            <div id="load_icon_create_ftp" order="{{ order_name }}" style="display:none">
                Отправление запроса <img alt="загрузка" src="{{ asset('bundles/billing/i/load.gif') }}">
            </div>
        </div>
        </form>

        <div class="c">
            <table>
            <tr>
                <td align="right">
                    <a href="" id="add_ftp_link" class="action" order="{{ order_name }}">Добавить пользователя</a>
                </td>
                <td align="right">
                    <a href="" id="synch_ftp" class="action" order="{{ order_name }}">Синхронизировать пользователей</a>
                    <div id="load_icon_synch_ftp" order="{{ order_name }}" style="display:none">
                        Синхронизация FTP пользователей <img alt="загрузка" src="{{ asset('bundles/billing/i/load.gif') }}">
                    </div>
                    <div id="load_icon_synch_error" order="{{ order_name }}">
                    </div>
                </td>
            </tr>
            </table>
        </div>

        <div id="ftp_list" order="{{ order_name }}">
            <table class="table table-striped">
            <thead>
                    <tr>
                            <th>Имя пользователя</th>
                            <th>Путь</th>
                            <th>Пароль</th>
                    </tr>

            </thead>
            <tbody>
            {% for key, ftp in ftps %}

                    {% if ftp.getIsActive %}
                        {% include "BillingBundle:Orders_shared:user_index_active_ftp_template.html.twig" %}
                    {% else %}
                        {% include "BillingBundle:Orders_shared:user_index_not_active_ftp_template.html.twig" %}
                    {% endif %}

            {% endfor %}
            </tbody>
            </table>
        </div>
        <script type="text/javascript">
        var validator = $('#ftp_form[order="{{ order_name }}"]').validate({
                rules: {
                        ftp_user_name: {
                                required: true,
                                maxlength: 64,
                                check_ftp: true
                        },
                        ftp_new_password: {
                                required: true,
                                maxlength: 64,
                                minlength: 5,
                                check_password: true
                        },
                        ftp_directory: {
                                check_dir: true,
                                required: true,
                                maxlength: 100
                        }
                },
                messages: {
                        ftp_user_name: {
                                required: "Введите имя",
                                maxlength: jQuery.format("Не более {0} символов")
                        },
                        ftp_new_password: {
                                required: "Введите пароль",
                                maxlength: jQuery.format("Не более {0} символов"),
                                minlength: jQuery.format("Не менее {0} символов")
                        },
                        ftp_directory: {
                                required: "Введите директорию",
                                maxlength: jQuery.format("Не более {0} символов")
                        }

                },

                errorPlacement: function(error, element) {
                        error.appendTo( element.parent().next() );
                },
                success: function(label) {
                        // set &nbsp; as text for IE
                        label.html("&nbsp;").addClass("checked");
                }
        });
        </script>
</div>

